<?php

use App\Http\Controllers\ProvisionServer;
use App\Http\Controllers\UserController;
use App\Http\Controllers\PhotoController;
use App\Models\Task;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Redis;

Route::get('/', function () {
    return view('welcome');
});

Route::get('/greeting/{name?}', function (Request $request, ?string $name = 'zgj') {
    return view('greeting', ['name' => $name,
     'host' => $request->host(), 
     'httpHost' => $request->httpHost(), 
     'schemaAndHttpHost' => $request->schemeAndHttpHost(),
     'getHost' => $request->getHost(),
     'method' => $request->method(),
     'ip' => $request->ip(),
     'ips' => implode(',', $request->ips()),
    ]);
})->where('name', '.*')->name('greeting');

Route::get('/profile', function() {
    return view('profile');
});

Route::get('/user/{id}', [UserController::class,'show'])->where('id', '[0-9]+');

Route::post('/server', ProvisionServer::class);

Route::get('/tasks', function() {
    return view('tasks', ['tasks' => Task::all()]);
});

Route::get('/child', function() {
    return view('child');
});

Route::resource('photos', PhotoController::class);

Route::get('/user/index', [UserController::class,'index']);

Route::get('/publish', function () {
    $redis = app('redis');
    $redis->command('set', ['name', 'zgj1ww1']);
    $redis->publish('test-channel', 'asdfsa');

});